package com.keyidea.jfxui.core;

import com.keyidea.jfxui.core.system.sqlite.entity.User;
import com.keyidea.jfxui.core.system.sqlite.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TestService {

    @Autowired
    UserMapper userMapper;

    /**
     * 增添数据
     */
    public Object insert(String name) {
        User user = new User();
        user.setUserName(name);
        return userMapper.insert(user);
    }

    /**
     * 查询数据
     */
    public Object show() {
        return userMapper.selectList(null);
    }

    /**
     * 删除数据
     */
    public Object delete(Integer id) {
        return userMapper.deleteById(id);
    }

    /**
     * 修改数据
     */
    public Object update(Integer id, String name) {
        User user = new User();
        user.setUserId(id);
        user.setUserName(name);
        return userMapper.updateById(user);
    }
}
